import Vue from 'vue'
import Router from 'vue-router'

Vue.use(Router)
// 获取原型对象上的push函数
const originalPush = Router.prototype.push
// 修改原型对象中的push方法
Router.prototype.push = function push (location) {
  return originalPush.call(this, location).catch(err => err)
}
export default new Router({
  routes: [
    // 登录页
    {
      path: '/login',
      name: 'login',
      component: () => import('../views/Login.vue')
    },
    // 首页
    {
      path: '/homepage',
      name: 'homepage',
      component: () => import('../views/HomePage.vue'),
      children: [
        // 个人中心
        {
          path: 'personalcenter',
          name: 'personalcenter',
          component: () => import('../views/personalCenter/index.vue')
        },
        // element-ui--------------------------------------------------------------------------
        // 完整功能表格
        {
          path: 'table',
          name: 'table',
          component: () => import('../components/Element-ui/Table.vue')
        },
        // 行内编辑表格
        {
          path: 'edittable',
          name: 'edittable',
          component: () => import('../components/Element-ui/EditTable.vue')
        },
        // 富文本编辑器
        {
          path: 'tinymce',
          name: 'tinymce',
          component: () => import('../components/Tinymce/Tinymce.vue')
        },
        // 卡片
        {
          path: 'mycard',
          name: 'mycard',
          component: () => import('../components/Card/index.vue')
        },
        // 甘特图
        {
          path: 'ganttchart',
          name: 'ganttchart',
          component: () => import('../components/Gantt-chart/index.vue')
        },
        // threeJS
        {
          path: 'three',
          name: 'three',
          component: () => import('../components/Three3D/index.vue')
        },
        // demo
        {
          path: 'demo',
          name: 'demo',
          component: () => import('../components/Element-ui/demo.vue')
        },
      ]
    },
    // 默认显示页面
    {
      path: '/',
      redirect: 'login'
    }
  ]
})